#ifndef COMMONDEF_FUN_H
#define COMMONDEF_FUN_H
#include <stdio.h>

#ifdef _WIN32

//#ifdef TOOL_SDK_API_EXPORTS
//#define TOOL_SDK_API __declspec(dllexport)
//#else
//#define TOOL_SDK_API __declspec(dllimport)
//#endif
#ifdef _WINDLL

#ifdef TOOL_SDK_API_EXPORTS
#define TOOL_SDK_API __declspec(dllexport)
#else
#define TOOL_SDK_API __declspec(dllimport)
#endif

#else
#define TOOL_SDK_API 
#endif


#define DLL_SPEC __cdecl
#else
#define DLL_SPEC 
#define TOOL_SDK_API 
#endif

namespace libtool_sdk
{

#ifndef SAFE_MEM_FREE
#define SAFE_MEM_FREE(ptr)                          \
if (NULL != ptr)                                \
	{                                               \
	free((ptr));                       \
	(ptr) = NULL;                               \
	}
#endif


#ifndef SAFE_DELETE_OBJ
#define SAFE_DELETE_OBJ(pObj)                           \
if (pObj)                                       \
	{                                               \
	delete pObj;                                \
	pObj = NULL;                                \
	}
#endif

#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(pArrayObj)				\
if (pArrayObj)									\
	{												\
	delete[] pArrayObj;							\
	pArrayObj = NULL;							\
	}
#endif

#define TOOL_LOG_FMT(fmt,...) printf("%s:: " fmt, __FUNCTION__, ##__VA_ARGS__);

#define CHECK_PARAMATER_IF_NULL(paramater) \
{	\
    if (NULL == paramater) \
			    {	\
    TOOL_LOG_FMT("%s is NULL.", #paramater);	\
    return 0;	\
			    }	\
    }

#define CHECK_PARAMATER_LESS_THAN_ZERO(paramater) \
{	\
    if (paramater <= 0) \
			    {	\
    TOOL_LOG_FMT("%s is less than zero.", #paramater);	\
    return 0;	\
			    }	\
    }	
}
#endif
